using System;
using System.Collections.Generic;
using System.Text;
using PSE.Hosting.Management.Services.ServicesManager;

namespace PSE.Hosting.Management.Common
{
    /// <summary>
    /// Defines the methods a WCF Service Hoster Manager can call.
    /// </summary>
    public interface IServices
    {
        #region Assembly Services

        /// <summary>
        /// Gets a list of all WCF assemblies of the specified packaged.
        /// </summary>
        /// <param name="serverName">The server name containing the assemblies to list.</param>
        /// <param name="packageName">The package name containing the assemblies to list.</param>
        /// <returns>A list of all WCF assemblies of the specified package.</returns>
        List<AssemblyData> GetAssemblyList(string serverName, string packageName);

        // <summary>
        /// Starts all WCF services from a specific assembly.
        /// </summary>
        /// <param name="serverName">The name of the server containing the assembly to start.</param>
        /// <param name="packageName">The name of the package of the assembly to start.</param>
        /// <param name="fileName">The name of the assembly file to start. This is the filename only, without the path.</param>
        void StartAssembly(string serverName, string packageName, string fileName);

        /// <summary>
        /// Stops all WCF services from a specific assembly.
        /// </summary>
        /// <param name="serverName">The name of the server containing the assembly to stop.</param>
        /// <param name="packageName">The name of the package containing the assembly to stop.</param>
        /// <param name="fileName">The name of the assembly file to stop. This is the filename only, without the path.</param>
        void StopAssembly(string serverName, string packageName, string fileName);

        /// <summary>
        /// Adds an assembly to the Service Hoster.
        /// </summary>
        /// <param name="serverName">The name of the server where the Service Hoster is installed.</param>
        /// <param name="packageName">The name of the package where the assembly will be added.</param>
        /// <param name="assembly">The name of the assembly taht will be added.</param>
        /// <param name="codeBase">The path of the assembly that will be added.</param>
        /// <param name="domain">The domain name of the user to load the assembly. (Used only when the assembly must be loaded with elevated permissions).</param>
        /// <param name="userName">The user name to load the assembly. (Used only when the assembly must be loaded with elevated permissions).</param>
        /// <param name="password">The password of the user to load the assembly. (Used only when the assembly must be loaded with elevated permissions).</param>
        void AddAssembly(string serverName, string packageName, string assembly, string codeBase/*, string domain, string userName, string password*/);

        /// <summary>
        /// Removes an assembly from the Service Hoster.
        /// </summary>
        /// <param name="serverName">The name of the server where the assembly resides.</param>
        /// <param name="packageName">The name of the package containing the assembly to be removed.</param>
        /// <param name="fileName">The name of the assembly to be removed.</param>
        void RemoveAssembly(string serverName, string packageName, string fileName);

        #endregion

        #region Package Services

        // <summary>
        /// Get a list of the packages created in a specific server.
        /// </summary>
        /// <param name="serverName">The name of the server.</param>
        /// <returns>A list of packages.</returns>
        List<PackageData> GetPackageList(string serverName);

        /// <summary>
        /// Adds a package to a specific server.
        /// </summary>
        /// <param name="serverName">The name of the server.</param>
        /// <param name="packageName">The name of the package to be created.</param>
        void AddPackage(string serverName, string packageName, string domain, string userName, string password);

        /// <summary>
        /// Updates a package to a specific server.
        /// </summary>
        /// <param name="serverName">The name of the server.</param>
        /// <param name="packageName">The name of the package to be created.</param>
        void UpdatePackage(string serverName, string packageName, string domain, string userName, string password);

        /// <summary>
        /// Removes a package from a specific server.
        /// </summary>
        /// <param name="serverName">The name of the server.</param>
        /// <param name="packageName">The name of the package to be removed.</param>
        void RemovePackage(string serverName, string packageName);

        /// <summary>
        /// Starts all the assemblies from a specific package.
        /// </summary>
        /// <param name="serverName">The name of the server containing the package to be started.</param>
        /// <param name="packageName">The name of the package to be started.</param>
        void StartPackage(string serverName, string packageName, bool startAssemblies);

        /// <summary>
        /// Stop all the assemblies from a specific package.
        /// </summary>
        /// <param name="serverName">The name of the server containing the package to be started.</param>
        /// <param name="packageName">The name of the package to be started.</param>
        void StopPackage(string serverName, string packageName);

        /// <summary>
        /// Stop all the assemblies from a specific package.
        /// </summary>
        /// <param name="serverName">The name of the server containing the package to be started.</param>
        /// <param name="packageName">The name of the package to be started.</param>
        void StopPackage(string serverName, string packageName, bool save);

        /// <summary>
        /// Starts all the assemblies from a specific package asynchronously.
        /// </summary>
        /// <param name="serverName">The name of the server containing the package to be started.</param>
        /// <param name="packageName">The name of the package to be started.</param>
        void StartPackageAsynchronous(string serverName, string packageName, bool startAssemblies);

        #endregion

        #region Service Services

        /// <summary>
        /// Get a list of services from a specific assembly.
        /// </summary>
        /// <param name="serverName">The name of the server where the assembly resides.</param>
        /// <param name="packageName">The name of the package containing the assembly.</param>
        /// <param name="fileName">The name of the assembly to ge t the list of services.</param>
        /// <returns>A list of services from an assembly.</returns>
        List<ServiceData> GetServiceList(string serverName, string packageName, string fileName);

        /// <summary>
        /// Starts a WCF service.
        /// </summary>
        /// <param name="serverName">The name of the server hosting the service.</param>
        /// <param name="packageName">The name of the package where the assembly containing the service is.</param>
        /// <param name="fileName">The name of the file containing the service.</param>
        /// <param name="serviceName">The name of the service to be started.</param>
        void StartService(string serverName, string packageName, string fileName, string serviceName);

        /// <summary>
        /// Stops a WCF service.
        /// </summary>
        /// <param name="serverName">The name of the server hosting the service.</param>
        /// <param name="packageName">The name of the package where the assembly containing the service is.</param>
        /// <param name="fileName">The name of the file containing the service.</param>
        /// <param name="serviceName">The name of the service to be stopped.</param>
        void StopService(string serverName, string packageName, string fileName, string serviceName);

        #endregion

        #region Windows Startup Services

        /// <summary>
        /// Starts the WCF Service Hoster Windows Service.
        /// </summary>
        /// <param name="serverName">The name of the server where the windows service is installed.</param>
        void StartWindowsService(string serverName, bool asynchronous, bool startAll);

        /// <summary>
        /// Stops the WCF Service Hoster Windows Service.
        /// </summary>
        /// <param name="serverName">The name of the server where the windows service is installed.</param>
        void StopWindowsService(string serverName);

        #endregion
    }
}
